<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QInputContext Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QInputContext Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QInputContext class abstracts the input method dependent
data and composing state. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qinputcontext.html#StandardFormat-enum">StandardFormat</a></b> { PreeditFormat, SelectionFormat }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qinputcontext.html#QInputContext">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />list-of-QAction <b><a href="qinputcontext.html#actions">actions</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qinputcontext.html#filterEvent">filterEvent</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" />QWidget <b><a href="qinputcontext.html#focusWidget">focusWidget</a></b> (<i>self</i>)</li><li><div class="fn" />QFont <b><a href="qinputcontext.html#font">font</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qinputcontext.html#identifierName">identifierName</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qinputcontext.html#isComposing">isComposing</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qinputcontext.html#language">language</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#mouseHandler">mouseHandler</a></b> (<i>self</i>, int&#160;<i>x</i>, QMouseEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#reset">reset</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#sendEvent">sendEvent</a></b> (<i>self</i>, QInputMethodEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#setFocusWidget">setFocusWidget</a></b> (<i>self</i>, QWidget&#160;<i>w</i>)</li><li><div class="fn" />QTextFormat <b><a href="qinputcontext.html#standardFormat">standardFormat</a></b> (<i>self</i>, StandardFormat&#160;<i>s</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#update">update</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qinputcontext.html#widgetDestroyed">widgetDestroyed</a></b> (<i>self</i>, QWidget&#160;<i>w</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QInputContext class abstracts the input method dependent
data and composing state.</p>
<p>An input method is responsible for inputting complex text that
cannot be inputted via simple keymap. It converts a sequence of
input events (typically key events) into a text string through the
input method specific converting process. The class of the
processes are widely ranging from simple finite state machine to
complex text translator that pools a whole paragraph of a text with
text editing capability to perform grammar and semantic
analysis.</p>
<p>To abstract such different input method specific intermediate
information, Qt offers the QInputContext as base class. The concept
is well known as 'input context' in the input method domain. An
input context is created for a text widget in response to a demand.
It is ensured that an input context is prepared for an input method
before input to a text widget.</p>
<p>Multiple input contexts that belong to a single input method may
concurrently coexist. Suppose multi-window text editor. Each text
widget of window A and B holds different QInputContext instance
which contains different state information such as partially
composed text.</p>
<a id="groups-of-functions" name="groups-of-functions" />
<h3>Groups of Functions</h3>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Context</th>
<th>Functions</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td>Receiving information</td>
<td><a href="qinputcontext.html#x11FilterEvent">x11FilterEvent</a>(), <a href="qinputcontext.html#filterEvent">filterEvent</a>(), <a href="qinputcontext.html#mouseHandler">mouseHandler</a>()</td>
</tr>
<tr class="even" valign="top">
<td>Sending back composed text</td>
<td><a href="qinputcontext.html#sendEvent">sendEvent</a>()</td>
</tr>
<tr class="odd" valign="top">
<td>State change notification</td>
<td><a href="qinputcontext.html#setFocusWidget">setFocusWidget</a>(), <a href="qinputcontext.html#reset">reset</a>()</td>
</tr>
<tr class="even" valign="top">
<td>Context information</td>
<td><a href="qinputcontext.html#identifierName">identifierName</a>(), <a href="qinputcontext.html#language">language</a>(), <a href="qinputcontext.html#font">font</a>(), <a href="qinputcontext.html#isComposing">isComposing</a>()</td>
</tr>
</table>
<a id="licensing-information" name="licensing-information" />
<h3>Licensing Information</h3>
<div class="LegaleseLeft">
<p>Copyright (C) 2003-2004 immodule for Qt Project. All rights
reserved.</p>
<p>This file is written to contribute to Nokia Corporation and/or
its subsidiary(-ies) under their own license. You may use this file
under your Qt license. Following description is copied from their
original file headers. Contact immodule-qt@freedesktop.org if any
conditions of this licensing are not clear to you.</p>
</div>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="StandardFormat-enum" />QInputContext.StandardFormat</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QInputContext.PreeditFormat</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">The preedit text.</td>
</tr>
<tr>
<td class="topAlign"><tt>QInputContext.SelectionFormat</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The selection text.</td>
</tr>
</table>
<p><b>See also</b> <a href="qinputcontext.html#standardFormat">standardFormat</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QInputContext" />QInputContext.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs an input context with the given <i>parent</i>.</p>


<h3 class="fn"><a name="actions" />list-of-QAction QInputContext.actions (<i>self</i>)</h3><p>This is a preliminary interface for Qt 4.</p>


<h3 class="fn"><a name="filterEvent" />bool QInputContext.filterEvent (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>This function can be reimplemented in a subclass to filter input
events.</p>
<p>Return true if the <i>event</i> has been consumed. Otherwise,
the unfiltered <i>event</i> will be forwarded to widgets as
ordinary way. Although the input events have accept() and ignore()
methods, leave it untouched.</p>
<p><i>event</i> is currently restricted to events of these
types:</p>
<ul>
<li>CloseSoftwareInputPanel</li>
<li>KeyPress</li>
<li>KeyRelease</li>
<li>MouseButtonDblClick</li>
<li>MouseButtonPress</li>
<li>MouseButtonRelease</li>
<li>MouseMove</li>
<li>RequestSoftwareInputPanel</li>
</ul>
<p>But some input method related events such as <a href="qwheelevent.html">QWheelEvent</a> or <a href="qtabletevent.html">QTabletEvent</a> may be added in future.</p>
<p>The filtering opportunity is always given to the input context
as soon as possible. It has to be taken place before any other key
event consumers such as eventfilters and accelerators because some
input methods require quite various key combination and sequences.
It often conflicts with accelerators and so on, so we must give the
input context the filtering opportunity first to ensure all input
methods work properly regardless of application design.</p>
<p>Ordinary input methods require discrete key events to work
properly, so Qt's key compression is always disabled for any input
contexts.</p>
<p><b>See also</b> <a href="qkeyevent.html">QKeyEvent</a> and
<a href="qinputcontext.html#x11FilterEvent">x11FilterEvent</a>().</p>


<h3 class="fn"><a name="focusWidget" /><a href="qwidget.html">QWidget</a> QInputContext.focusWidget (<i>self</i>)</h3><p>Returns the widget that has an input focus for this input
context.</p>
<p>The return value may differ from holderWidget() if the input
context is shared between several text widgets.</p>
<p><b>Warning:</b> To ensure platform independence and support
flexible configuration of widgets, ordinary input methods should
not call this function directly.</p>
<p><b>See also</b> <a href="qinputcontext.html#setFocusWidget">setFocusWidget</a>().</p>


<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QInputContext.font (<i>self</i>)</h3><p>Returns the font of the current input widget</p>


<h3 class="fn"><a name="identifierName" />QString QInputContext.identifierName (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function must be implemented in any subclasses to return
the identifier name of the input method.</p>
<p>Return value is the name to identify and specify input methods
for the input method switching mechanism and so on. The name has to
be consistent with <a href="qinputcontextplugin.html#keys">QInputContextPlugin.keys</a>().
The name has to consist of ASCII characters only.</p>
<p>There are two different names with different responsibility in
the input method domain. This function returns one of them. Another
name is called 'display name' that stands for the name for endusers
appeared in a menu and so on.</p>
<p><b>See also</b> <a href="qinputcontextplugin.html#keys">QInputContextPlugin.keys</a>() and
<a href="qinputcontextplugin.html#displayName">QInputContextPlugin.displayName</a>().</p>


<h3 class="fn"><a name="isComposing" />bool QInputContext.isComposing (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function indicates whether InputMethodStart event had been
sent to the current focus widget. It is ensured that an input
context can send InputMethodCompose or InputMethodEnd event safely
if this function returned true.</p>
<p>The state is automatically being tracked through <a href="qinputcontext.html#sendEvent">sendEvent</a>().</p>
<p><b>See also</b> <a href="qinputcontext.html#sendEvent">sendEvent</a>().</p>


<h3 class="fn"><a name="language" />QString QInputContext.language (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function must be implemented in any subclasses to return a
language code (e.g. "zh_CN", "zh_TW", "zh_HK", "ja", "ko", ...) of
the input context. If the input context can handle multiple
languages, return the currently used one. The name has to be
consistent with QInputContextPlugin.language().</p>
<p>This information will be used by language tagging feature in
<a href="qinputmethodevent.html">QInputMethodEvent</a>. It is
required to distinguish unified han characters correctly. It
enables proper font and character code handling. Suppose CJK-awared
multilingual web browser (that automatically modifies fonts in
CJK-mixed text) and XML editor (that automatically inserts lang
attr).</p>


<h3 class="fn"><a name="mouseHandler" />QInputContext.mouseHandler (<i>self</i>, int&#160;<i>x</i>, <a href="qmouseevent.html">QMouseEvent</a>&#160;<i>event</i>)</h3><p>This function can be reimplemented in a subclass to handle mouse
press, release, double-click, and move events within the preedit
text. You can use the function to implement mouse-oriented user
interface such as text selection or popup menu for candidate
selection.</p>
<p>The <i>x</i> parameter is the offset within the string that was
sent with the InputMethodCompose event. The alteration boundary of
<i>x</i> is ensured as character boundary of preedit string
accurately.</p>
<p>The <i>event</i> parameter is the event that was sent to the
editor widget. The event type is <a href="qevent.html#Type-enum">QEvent.MouseButtonPress</a>, <a href="qevent.html#Type-enum">QEvent.MouseButtonRelease</a>, <a href="qevent.html#Type-enum">QEvent.MouseButtonDblClick</a> or <a href="qevent.html#Type-enum">QEvent.MouseMove</a>. The event's button
and state indicate the kind of operation that was performed.</p>


<h3 class="fn"><a name="reset" />QInputContext.reset (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>This function can be reimplemented in a subclass to reset the
state of the input method.</p>
<p>This function is called by several widgets to reset input state.
For example, a text widget call this function before inserting a
text to make widget ready to accept a text.</p>
<p>Default implementation is sufficient for simple input method.
You can override this function to reset external input method
engines in complex input method. In the case, call
QInputContext.reset() to ensure proper termination of
inputting.</p>
<p>In a reimplementation of reset(), you must not send any <a href="qinputmethodevent.html">QInputMethodEvent</a> containing preedit
text. You can only commit string and attributes; otherwise, you
risk breaking input state consistency.</p>


<h3 class="fn"><a name="sendEvent" />QInputContext.sendEvent (<i>self</i>, <a href="qinputmethodevent.html">QInputMethodEvent</a>&#160;<i>event</i>)</h3><p>Sends an input method event specified by <i>event</i> to the
current focus widget. Implementations of <a href="qinputcontext.html">QInputContext</a> should call this method to
send the generated input method events and not <a href="qcoreapplication.html#sendEvent">QApplication.sendEvent</a>(), as
the events might have to get dispatched to a different application
on some platforms.</p>
<p>Some complex input methods route the handling to several child
contexts (e.g. to enable language switching). To account for this,
<a href="qinputcontext.html">QInputContext</a> will check if the
parent object is a <a href="qinputcontext.html">QInputContext</a>.
If yes, it will call the parents sendEvent() implementation instead
of sending the event directly.</p>
<p><b>See also</b> <a href="qinputmethodevent.html">QInputMethodEvent</a>.</p>


<h3 class="fn"><a name="setFocusWidget" />QInputContext.setFocusWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>w</i>)</h3><p>Sets the <i>widget</i> that has an input focus for this input
context.</p>
<p><b>Warning:</b> Ordinary input methods must not call this
function directly.</p>
<p><b>See also</b> <a href="qinputcontext.html#focusWidget">focusWidget</a>().</p>


<h3 class="fn"><a name="standardFormat" /><a href="qtextformat.html">QTextFormat</a> QInputContext.standardFormat (<i>self</i>, <a href="qinputcontext.html#StandardFormat-enum">StandardFormat</a>&#160;<i>s</i>)</h3><p>Returns a <a href="qtextformat.html">QTextFormat</a> object that
specifies the format for component <i>s</i>.</p>


<h3 class="fn"><a name="update" />QInputContext.update (<i>self</i>)</h3><p>This virtual function is called when a state in the focus widget
has changed. <a href="qinputcontext.html">QInputContext</a> can
then use <a href="qwidget.html#inputMethodQuery">QWidget.inputMethodQuery</a>() to
query the new state of the widget.</p>


<h3 class="fn"><a name="widgetDestroyed" />QInputContext.widgetDestroyed (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>w</i>)</h3><p>This virtual function is called when the specified <i>widget</i>
is destroyed. The <i>widget</i> is a widget on which this input
context is installed.</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>